<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Ionize, creative CMS
 *
 * @package		Ionize
 * @author		Ionize Dev Team
 * @license		http://ionizecms.com/doc-license
 * @link		http://ionizecms.com
 * @since		Version 0.9.0
 */

// ------------------------------------------------------------------------

/**
 * Ionize, creative CMS Article Controller
 *
 * @package		Ionize
 * @subpackage	Controllers
 * @category	Article
 * @author		Ionize Dev Team
 *
 */
 
class pr_gallery_cl extends MY_admin 
{

	/**
	 * Fields on wich the htmlspecialchars function will not be used before saving
	 * 
	 * @var array
	 */
	/**
	 * Fields on wich no XSS filtering is done
	 * 
	 * @var array
	 */
	/**
	 * Constructor
	 *
	 */
	public function __construct()
	{
		parent::__construct();
		// product model
		$this->load->model('pr_fnc_model', '', true);
		//$this->load->model('sibilling_model', '', true);
	}

	// ------------------------------------------------------------------------
	/**
	 * Default : Do nothing
	 *
	 */
	function index()
	{
		//point to pr_tab_categroy view, then pr_tab_categroy point to category_info panel
		$data=$this->pr_fnc_model->get_all('tbl_category');
		$this->template['category_data']=$data;
		$this->output('pr_tab_category');
	}
	// Listing gallery
	function get_list_gallery($page = 1)
	{
		$wheres = '';
		//$code = $this->sibilling_model->get_by_field('branchs', 'id', $this->session->userdata('branchs_id'));
		
		$limit_p = '50';
		$nb = ($this->input->post('nb')) ? $this->input->post('nb') : $limit_p;
		
		// Minimum
		if ($nb < $limit_p)	$nb = $limit_p;
	
		$page 	= $page - 1;		
		$offset = $page * $nb;				

		
		if(count($this->input->post()) > 1)
			$posts	= $this->input->post();
			
			
		$this->template['ip_accTest'] = $this->pr_fnc_model->get_by_sql("SELECT * FROM tbl_product order by pd_id DESC LIMIT {$nb} OFFSET {$offset} ");	
		
		$data = '';
		if(count($this->template['ip_accTest']) > 0){
			foreach($this->template['ip_accTest'] as $info):
			
				$data .= '<tr class="even" onmouseover="this.className=\'odd\'" onmouseout="this.className=\'even\'">
							<td>'.$info['pd_id'].'</td>
							<td>'.$info['cat_id'].'</td>            
							<td>'.$info['pd_name'].'</td>
							<td>'.$info['pd_price'].'</td>
							<td>'.$info['pd_des'].'</td>  
							<td>'.$info['pd_image'].'</td>
							<td class="center">
								<a class="icon info odf center" id="'.$info['pd_id'].'" rel="'.$info['pd_id'].'" style="display:inline-block"></a></td> 
							<td class="center">
								<a class="icon info ip center" id="'.$info['pd_id'].'" rel="'.$info['pd_id'].'" style="display:inline-block"></a></td>';       
				$data .= '</tr>';	
				
			endforeach;
		
		}else{
				$data .= '<tr><td colspan="14" style="text-align: center; color:#900;">No Record..</td></tr>';
		}
		$this->template['data'] = $data;
		
		// Pagination
		$this->template['current_page'] = $page + 1;
		$this->template['nb'] = $nb;
		$count=$this->template['count'] = $this->pr_fnc_model->count_by_sql('SELECT * FROM tbl_product ORDER BY pd_id DESC');
		trace($count);
		$pages=$this->template['pages'] = ceil($this->template['count'] / $nb);
		trace($pages);	
		
		$this->output('pr_gallery_tab');
	}
	
}


/* End of file article.php */
/* Location: ./application/controllers/admin/article.php */